﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FlowerShop.Models;

namespace FlowerShop.Controllers
{
    public class PaidTypeController : Controller
    {
        FlowerDBEntities db = new FlowerDBEntities();
        //
        // GET: /PaidType/

        public ActionResult Index()
        {
            return View(DataAccessLayer.PaidTypesDAO.GetAllPaidTypes());
        }

        //
        // GET: /PaidType/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /PaidType/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /PaidType/Create

        [HttpPost]
        public ActionResult Create(PaidTypeModels Paid)
        {
            try
            {
                // TODO: Add insert logic here
                DataAccessLayer.PaidTypesDAO.InsertPaidTypes(Paid);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /PaidType/Edit/5
 
        public ActionResult Edit(int id)
        {
            var pai = DataAccessLayer.PaidTypesDAO.SearchPaidTypes(id);
            PaidTypeModels paid = Mapper.paidtypeToModels(pai);
            return View(paid);
        }

        //
        // POST: /PaidType/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, PaidTypeModels Paid)
        {
            try
            {
                // TODO: Add update logic here
                DataAccessLayer.PaidTypesDAO.UpdatePaidTypes(Paid);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /PaidType/Delete/5
 
        public ActionResult Delete(int id)
        {
            DataAccessLayer.PaidTypesDAO.DeletePaidTypes(id);
            return View();
        }

        //
        // POST: /PaidType/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
